/*
 * FLRFile.h
 *
 *  Created on: Sep 19, 2011
 *      Author: kimi
 */

#ifndef FLRFILE_H_
#define FLRFILE_H_

#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include "../EmptySpaceMgr.h"

using namespace std;


class FLRFile {

public:

	// getByID
	bool getRecordByID(unsigned long recordID, char** record);

	// unsigned long add(reg) - agrega al final . devuelve record ID
	bool addRecord(unsigned long *recordID, char* record);

	//
	bool updateRecord(unsigned long recordID, char* record);

	//
	bool deleteRecord(unsigned long recordID);

	// truncate a los 'recordCount' registros (exclusive)
	bool truncateFile(unsigned long recordCount);

	FLRFile(string filePath,unsigned long regSize);
	virtual ~FLRFile();

	unsigned long getRecordCount();
	unsigned long getRecordSize();

	void purge();

private:

	unsigned long	recordSize;
	unsigned long	recordCount;

	fstream	_file;
	string	filePath;

	// empty space manager
	EmptySpaceMgr *spaceMgr;

};


#endif /* FLRFILE_H_ */
